package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.IDeleteVo;
import com.msh.frame.client.validation.IInsertVo;
import com.msh.frame.client.validation.IUpdateVo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Date;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @author shihu
 * @email m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(title = "运行中制品Po")
public class ModuleRunningPo extends BasePo {

  /**
   * 主键id
   */
  @NotNull(groups = {IUpdateVo.class, IDeleteVo.class}, message = "不能为空")
  @Schema(title = "主键id")
  private Long id;

  /**
   * 制品
   */
  @NotNull(groups = {IInsertVo.class}, message = "制品不能为空")
  @Schema(title = "制品")
  private Long moduleId;

  /**
   * 制品构建
   */
  @NotNull(groups = {IInsertVo.class}, message = "制品构建不能为空")
  @Schema(title = "制品构建")
  private Long moduleBuildId;

  /**
   * 环境
   */
  @Schema(title = "环境")
  private Long envId;

  /**
   * 名称
   */
  @Schema(title = "名称")
  private String name;

  /**
   * 版本
   */
  @Schema(title = "版本")
  private Integer version;

  /**
   * 分支
   */
  @Size(groups = {IUpdateVo.class, IInsertVo.class}, max = 50, message = "branch长度范围最大50")
  @Schema(title = "分支")
  private String branch;

  /**
   * 运行类型
   */
  @Schema(title = "运行类型")
  private String runningType;

  /**
   * header的key
   */
  @Size(groups = {IUpdateVo.class, IInsertVo.class}, max = 20, message = "headerKey长度范围最大20")
  @Schema(title = "header的key")
  private String headerKey;

  /**
   * header的value
   */
  @Size(groups = {IUpdateVo.class,
      IInsertVo.class}, max = 20, message = "headerValue长度范围最大20")
  @Schema(title = "header的value")
  private String headerValue;

  /**
   * 副本数
   */
  @Min(value = 0, message = "scale最小为0")
  @Max(value = 10, message = "scale最大为10")
  @Schema(title = "副本数")
  private Integer scale;

  /**
   * 租户id
   */
  @Schema(title = "租户id")
  private Long tenantId;

  /**
   * 创建时间
   */
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @Schema(title = "创建时间")
  private Date createTime;

  /**
   * 修改时间
   */
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @Schema(title = "修改时间")
  private Date updateTime;


  public void initLoginAccount(ILoginAccount loginAccount) {
    this.tenantId = loginAccount.getTenantId();
  }
}



